package algorithms.bloom;
import configuration.Configuration;
import simulator.Client;
import simulator.Manager;
import storage.Disk;
/**
* @author Nodirjon Siddikov
*/
public class NonBloomManager extends Manager
{
private NonBloomClient[] _clients;
public NonBloomManager(int id, Disk disk)
{
super(id, disk);
_clients = new NonBloomClient[Configuration.noOfClients];
}
//get the list of clients but one
public NonBloomClient[] getAllClients(int clientID)
{
NonBloomClient[] _reducedList = new NonBloomClient[Configuration.noOfClients - 1];
int index = 0;
for(NonBloomClient clnt: _clients)
{
if(clnt.getID() == clientID)
{
continue;
}
else
{
_reducedList[index] = clnt;
index++;
}
}
return _reducedList;
}
public NonBloomClient[] getAllClients()
{
return _clients;
}
//set the clients for the manager
public void setClients(Client[] clients)
{
//get the list of clients
for(int i = 0; i < clients.length; i++)
{
_clients[i] = (NonBloomClient)clients[i];
}
}
//get client reference
public NonBloomClient getClient(int id)
{
for(NonBloomClient c: _clients)
{
if(c.getID() == id)
{
return c;
}
}
//returns null if there is no a Client with such ID
return null;
}
public int getGlobalCacheSize()
{
int ttlCoopCacheSize = 0;
//calculate client coop cache size
for(NonBloomClient c: _clients)
{
ttlCoopCacheSize += c.getClientCoopCacheSize();
}
return ttlCoopCacheSize;
}
}